//
//  RootViewController.m
//  UI01_UILabel
//
//  Created by ZhiPeng.Y on 15/10/7.
//  Copyright © 2015年 Mr.Yuzhipeng. All rights reserved.
//

#import "RootViewController.h"

@interface RootViewController ()

@end

@implementation RootViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    
    //创建label
    UILabel *myLabel = [[UILabel alloc] initWithFrame:CGRectMake(100, 100, 200, 100)];
    myLabel.backgroundColor = [UIColor redColor];
    [self.view addSubview:myLabel];
    [myLabel release];
    
    //添加文本
    myLabel.text = @"labelText";
    //设置边框
    myLabel.layer.borderWidth = 1;
    //设置边框颜色
    myLabel.layer.borderColor = [UIColor blackColor].CGColor;
    //设置圆角
    myLabel.layer.cornerRadius = 2;
    //隐藏多余部分
    myLabel.layer.masksToBounds = YES;
    //设置文本对齐方式
    myLabel.textAlignment = NSTextAlignmentCenter;
    //设置文本行数 (0是默认最大行数)
    myLabel.numberOfLines = 0;
    //设置文本内容的颜色
    myLabel.textColor = [UIColor blueColor];
    //让label自己根据文字的多少来自适应对应的宽度
//    [myLabel sizeToFit];
    //设置断行模式
    myLabel.lineBreakMode = NSLineBreakByTruncatingMiddle;
    //设置字体大小(默认17)
    myLabel.font = [UIFont systemFontOfSize:20.0];
    //文本字体(黑体加粗,20号字)
    myLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:20];
    //设置阴影的颜色
    myLabel.shadowColor = [UIColor grayColor];
    //设置阴影偏移量
    myLabel.shadowOffset = CGSizeMake(10, 10);
    
    //定时器
    //第一个参数:NSTimerInterval 时间间隔,设置每执行一次的时间
    //第二个参数:target  设置动作的执行人,一般是self
    //第三个参数:selector  设置执行的方法,需要写个方法
    //第四个参数:为空
    //第五个参数:repeats 设置是否重复
    
    [NSTimer scheduledTimerWithTimeInterval:3 target:self selector:@selector(text) userInfo:nil repeats:YES];

}

- (void)text {
    NSLog(@"计时器测试");
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
